import Vue from "vue";
import Router from "vue-router";
import index from '../../imports/ui/components/index';
import home from '../../imports/ui/components/home';
import contacts from '../../imports/ui/components/contacts';
import found from '../../imports/ui/components/found';
import noFound from '../../imports/ui/components/noFound';
import mine from '../../imports/ui/components/mine';
import chatPage from '../../imports/ui/components/chat/chatPage';
import chatDetail from '../../imports/ui/components/chat/chatDetail';
import alterPage from   '../../imports/ui/components/chat/alterPage';
import search from '../../imports/ui/components/search';
import userBase from '../../imports/ui/components/user/userBase';
import userInfSet from '../../imports/ui/components/user/userInfSet';
import setRemarks from '../../imports/ui/components/user/setRemarks';
import login from '../../imports/ui/components/login/login';
import register from '../../imports/ui/components/login/register';
import addFriend from '../../imports/ui/components/friend/addFriend';
import addPage from '../../imports/ui/components/friend/addPage';
import mineDetail from '../../imports/ui/components/mine/mineDetail';
import changeNickname from '../../imports/ui/components/mine/changeNickname';
import changeWenum from '../../imports/ui/components/mine/changeWenum';
import setting from '../../imports/ui/components/mine/setting';
import addApply from '../../imports/ui/components/friend/addApply';
import addList from '../../imports/ui/components/friend/addList';
import friendCircle from '../../imports/ui/components/friendCircle/friendCircle';
import showDetail from '../../imports/ui/components/friendCircle/showDetail';
import createGroup from '../../imports/ui/components/group/createGroup';
import chatGroupPage from '../../imports/ui/components/chat/chatGroupPage';
import addNews from '../../imports/ui/components/group/addNews';
import removeUsers from '../../imports/ui/components/group/removeUsers';
import groupNotice from '../../imports/ui/components/group/groupNotice';
import setPacket from '../../imports/ui/components/packet/setPacket';
import getPacket from '../../imports/ui/components/packet/getPacket';
import payInf from '../../imports/ui/components/mine/payInf';
import payPage from '../../imports/ui/components/mine/payPage';
import recharge from '../../imports/ui/components/mine/recharge';

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router);

export default new Router({
  routes: [
    {
        path: "/",
      component: index,
      redirect:'/home',
      children:[
        {
          path:'home',
          component:home,
          meta:{index:0}
        },
        {
          path:'contacts',
          component:contacts,
          meta:{index:0}
        },
        {
          path:'found',
          component:found,
          meta:{index:0}
        },
      {
        path:'mine',
        component:mine,
        meta:{index:0}
      }
      ]
    },
    {
      path:'/search/:id',
      component:search,
      meta:{index:1}
    },
    {
      path:'/login',
      component:login,
      meta:{index:0}
    },
    {
      path:'/register',
      component:register,
      meta:{index:1}
    },
    {
        path:'/chatPage/:id',
        component:chatPage,
        meta:{index:1}
    },
    {
      path:'/chatGroupPage/:id',
      component:chatGroupPage,
      meta:{index:1}
  },
    {
      path:'/chatDetail/:id',
      component:chatDetail,
      meta:{index:2}
    },
     {
      path:'/alterPage/:id/:type',
      component:alterPage,
      meta:{index:3}
    },
    {
      path:'/userBase/:id',
      component:userBase,
      meta:{index:2}
    },
    {
      path:'/userInfSet/:id',
      component:userInfSet,
      meta:{index:3}
    },
    {
      path:'/setRemarks/:id',
      component:setRemarks,
      meta:{index:4}
    },
    {
      path:'/addFriend',
      component:addFriend,
      meta:{index:2}
    },
    {
      path:'/addPage',
      component:addPage,
      meta:{index:3}
    },
    {
      path:'/addApply/:id',
      component:addApply,
      meta:{index:1}
    },
    {
      path:'/addList',
      component:addList,
      meta:{index:1}
    },
    {
      path:'/mineDetail',
      component:mineDetail,
      meta:{index:1}
    },
    {
      path:'/changeNickname/:nickname',
      component:changeNickname,
      meta:{index:2}
    },
    {
      path:'/changeWenum/:weNum',
      component:changeWenum,
      meta:{index:2}
    },
    {
      path:'/setting/:id',
      component:setting,
      meta:{index:2}
    },
    {
      path:'/friendCircle',
      component:friendCircle,
      meta:{index:1}
    },
    {
      path:'/showDetail',
      component:showDetail,
      meta:{index:2}
    },
    {
      path:'/createGroup',
      component:createGroup,
      meta:{index:1}
    },
    {
      path:'/addNews/:id',
      component:addNews,
      meta:{index:3}
    },
    {
      path:'/removeUsers/:id',
      component:removeUsers,
      meta:{index:3}
    },
    {
      path:'/groupNotice/:id',
      component:groupNotice,
      meta:{index:3}
    },
    {
      path:'/setPacket/:id',
      component:setPacket,
      meta:{index:2}
    },
    {
      path:'/getPacket/:id',
      component:getPacket,
      meta:{index:2}
    },
    {
      path:'/payInf/:id',
      component:payInf,
      meta:{index:1}
    },
    {
      path:'/payPage/:id',
      component:payPage,
      meta:{index:2}
    },
    {
      path:'/recharge/:id',
      component:recharge,
      meta:{index:3}
    },
    {
      path:'/*',
      component:noFound,
      meta:{index:0}
    }
  ]
});
